<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="format-detection" content="telephone=no" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
		<script src="../../script/mui.min.js"></script>
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/swiper-3.4.2.min.css">
		<link rel="stylesheet" type="text/css" href="../../css/weui.min.css">
		<link rel="stylesheet" href="../../css/base.css"/>
		<link rel="stylesheet" href="../../css/exam.css">
		<title>签到进行中</title>
		<script type="text/javascript" charset="utf-8">
			mui.init();
		</script>
		<style>
			html {
				font-size: 10px;
			}
			#question_div {
				height: 400px
			}
			.weui_mask {
				position: fixed;
				z-index: 998;
				top: 0;
				right: 0;
				bottom: 0;
				left: 0;
			}
			.weui_dialog {
				z-index: 999;
			}
			.swiper-wrapper {
				min-height: 40rem
			}
			.close_sign_div {
				/*background: #18b4ed;*/
				color: #FFF;
				height: 45px;
			}
			.close_sign_div a {
				line-height: 45px;
				font-size: 14px;
				background: #18b4ed;
				width: 100%;
				color: #FFF;
			}
			/*.close_sign_div a:active {
			 background: #FF9900;
			 }*/
			.top_sign_info_div {
				margin-top: 20px;
				text-align: center
			}
			.center_sign_img_div {
				/*height: 180px;*/
				text-align: center;
			}
			.center_sign_img_div img {
				height: 280px;
				width: 280px;
			}
			.center_vote_div {
				margin-top: 20px;
				text-align: center;
			}
			.template_div img {
				width: 70%
			}
			.template_div p {
				padding-top: 10px
			}
			.info_img {
				line-height: 20px
			}
			.left_img {
				width: 40%;
				background: url(../../icon/vote_moban_select.png) no-repeat 24% 50%;
				background-size: 20px;
				color: #18b4ed;
				font-size: 14px;
				margin-left: 24px
			}
			.base_back_icon_right {
				height: 20px;
				position: absolute;
				top: 50%;
				right: 15px;
				margin-top: -11px;
			}
		</style>
	</head>
	<body >
		<div class="base_style_color" id='BarAppearance' style="height: 22px;width: 100%; position:fixed; left: 0px;top:0px;z-index: 998" ></div>
		<div class="base_navigation_bar base_style_color base_navigation_item_bar" style="position: fixed;left: 0px;top: 20px;">
			<a class="base_left_item" href="#" onclick="backToast()"> <img class="base_back_icon" src="../../image/icon_jiantou.png" alt=""> </a>
			<span id="title">投票</span>
			<a class="base_right_item nav-item" id="wancheng"onclick="historyClick()"> <img class="base_back_icon_right" src="../../image/icon_mutualrating__history.png" alt=""> </a>
		</div>
		<div class="stu-test " id="content_div" >
			<div class="ReviewWeekly_div  " style="margin-top: 64px"></div>
			<div class="space10"></div>
			<div class="k-con test-m-bottom70 test-analysis" id="question_div">
				<div class="top_sign_info_div">
					<span> 选择模板</span>
				</div>
				<div class="center_vote_div top_15" id="tab">
					<div class="template_div">
						<img   class="item_image" src="../../icon/icon_moban1_noselect.png" alt="" />
						<p style="visibility:hidden" class="info_img">
							<span class="left_img">已选</span>
						</p>
					</div>
					<div class="template_div top_20">
						<img   class="item_image" src="../../icon/icon_moban2_noselect.png" alt="" />
						<p style="visibility:hidden" class="info_img">
							<span class="left_img">已选</span>
						</p>
					</div>
				</div>
			</div>
			<div class="k-text-center k-fixed-bottom test-bottom1 close_sign_div" id="sub_div" onclick="SubmitToast()">
				<a>提交</a>
			</div>
		</div>
		<div id="backAlert" class="weui_dialog_confirm" style="display: none">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title" id="checkNum"></strong>
				</div>
				<div class="weui_dialog_bd"></div>
				<div class="weui_dialog_ft">
					<a  href="#" class="weui_btn_dialog default" id="closeTest_no" style="color:#18b4ed">取消</a>
					<a  href="#" class="weui_btn_dialog primary" id="closeTest_yes" style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/timeStampTool.js"></script>
	<script src="../../script/common.js"></script>
	<script type="text/javascript">
		var itemCheck = "3";
		var back_type = "";
		//1://退出 2:进入下一个页面
		apiready = function() {
			btnClick();
			SelectSwitch();
			sendBuriedNotifi('0', '老师端投票开启页', '214')
		};
		//历史记录
		function historyClick() {
			api.openWin({useWKWebView:true,
				name : 'Teacher_VoteHistoryWindow',
				url : 'Teacher_VoteHistoryWindow.html',
				pageParam : {
					cid : api.pageParam.cid,
					pid : api.pageParam.pid,
					sourceurl : window.location.pathname,
					sourcetitle : document.title
				},
			});
		}
		function sendBuriedNotifi(busionessid, pagetype, pagetypeid) {
			var userinfo = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				uname : $api.getStorage('cfnetppusername'),
			}
			var data = {
				busionessid : busionessid,
				pagetype : pagetype,
				pagetypeid : pagetypeid,
				sourceurl : api.pageParam.sourceurl,
				sourcetitle : api.pageParam.sourcetitle,
				accesspageurl : window.location.pathname,
				accesspagetitle : document.title,
				userinfo : userinfo
			}
			SendBehaviorTrajectoriesNotifi_Study(data);
		}

		function SelectSwitch() {
			var myTab = document.getElementById("tab");
			//一个节点
			var myLi = myTab.getElementsByClassName("template_div");
			var imgDiv = myTab.getElementsByClassName("item_image");
			var imgDiv2 = myTab.getElementsByClassName("info_img");
			//数组
			for (var i = 0; i < myLi.length; i++) {
				myLi[i].index = i;
				myLi[i].onclick = function() {
					for (var j = 0; j < myLi.length; j++) {
						if (j == 0) {//第1个
							imgDiv[j].setAttribute("src", "../../icon/icon_moban1_noselect.png");
						} else {
							imgDiv[j].setAttribute("src", "../../icon/icon_moban2_noselect.png");
						}
						imgDiv2[j].style.visibility = 'hidden';
					}
					if (this.index == 0) {//第1个
						imgDiv[this.index].setAttribute("src", "../../icon/icon_moban1_select.png");
					} else {
						imgDiv[this.index].setAttribute("src", "../../icon/icon_moban2_select.png");
					}
					imgDiv2[this.index].style.visibility = 'visible'
					itemCheck = this.index;
				}
			}
		}

		//提交数据
		function SubmitData() {
			var params = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				tid : 6,
				cid : api.pageParam.cid,
				pid : api.pageParam.pid,
				template : itemCheck,
			}
			cfnetppPOST(url_addActive, params, false, function(data, status) {
				SendBusinessOperationsLogNotifi('老师端投票开启', '214', params, params, '', data, '老师端投票开启接口', '214-01')
				hideProgress();
				if (status == 'success') {
					if (data.code == 200) {
						if (!isObjectEmpty(data)) {
							openVoteScore(data.iid)
						} else {
							ShowToast('暂无数据');
						}
					} else {
						ShowToast(data.message);
					}
				} else {
					ShowToast('投票开启失败');
				}
			})
		}

		//提交数据弹窗
		function SubmitToast() {
			if (itemCheck == "3") {
				alert('请选择模板');
				return false
			}
			//			$('#backAlert').show();
			//			$('#checkNum').text('是否确定开启投票？');
			showProgress();
			SubmitData()
			back_type = 2;
		}

		//按钮点击事件
		function btnClick() {
			//正常情况下是否退出当前考试按钮取消键
			$('#closeTest_no').click(function() {
				$('#backAlert').hide();
			});
			//正常情况下是否退出当前考试按钮确定键
			$('#closeTest_yes').click(function() {
				$('#backAlert').hide();
				sendBuriedNotifi('1', '老师端投票开启页', '214')
				if (back_type == 2) {
					showProgress();
					SubmitData()
				} else {
					api.closeWin({
					});
				}
			});
		}

		//打开投票结果页
		function openVoteScore(iid) {
			api.openWin({useWKWebView:true,
				name : 'Teacher_VoteScoreWindow',
				url : 'Teacher_VoteScoreWindow.html',
				pageParam : {
					iid : iid,
					itemCheck : itemCheck,
					ismocc : api.pageParam.ismocc,
					sourceurl : api.pageParam.sourceurl,
					sourcetitle : api.pageParam.sourcetitle,
					cid : api.pageParam.cid,
					pid : api.pageParam.pid,
				},
				slidBackEnabled : false,
			});
		}

		//退出提示
		function backToast() {
			$('#backAlert').show();
			$('#checkNum').text('是否确定退出当前投票页面?')
			back_type = 1;
		}

		//安卓系统返回键监听
		function keyback() {
			api.addEventListener({
				name : 'keyback'
			}, function(ret, err) {
				backToast()
			});
		}
	</script>
</html>